#!/usr/bin/python
# -*- coding: utf-8 -*-

from web.response import Response
from web.request import Request
from web.session import Session 
import web.page
from manager.employee_manager import EmployeeManager
import utils.common
import utils.log_utils as log

class Query(object):
    @utils.common.auth
    def handle(self, req, resp):  
        args = web.page.set_navbar_token(req, True)
        output = web.page.render('query.html', args) 
        return resp.respond(output)

class QueryHandler(object):
    @utils.common.auth
    @utils.common.check_token
    def handle(self, req, resp):  
        manager = EmployeeManager() 
        name = req.args.get('name')
        emplist = manager.query(name)
        if len(emplist) > 0:
            args = {'emps': emplist, 'setvisible':'visibility:visible'}
        else:
            args = {'emps': emplist, 'empty':u'没有找到数据，请注意查询条件。'}
        args.update(web.page.set_navbar_token(req, True))
        output = web.page.render('query.html', args) 
        return resp.respond(output)
